<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<%@ include file="/jsp/head.jsp"%>
	
	<%@ include file="/jsp/jslib.jsp"%>
	<script type="text/javascript">
	PAGE_CONFIG = {
		'MENU_INDEX' : 1,'LI_INDEX' : 1
	};
	</script>
	<script type="text/javascript" src="${ctx}/js/project.js"></script>
</head>
<body>

<%@ include file="/jsp/banner.jsp"%>
<div class="am-cf admin-main">
	<%@ include file="/jsp/menu.jsp"%>
	
	<!-- content start -->
	<div class="admin-content">
		<div class="admin-content-body">
		
		<!-- ***** 分离出去 动态加载 start ***** -->
		
	<div class="admin-content-body">
    <div class="am-cf am-padding am-padding-bottom-0">
      <div class="am-fl am-cf">
        <strong class="am-text-primary am-text-lg">创建项目机会</strong>
      </div>
    </div>

    <hr>
<form action="${ctx}/project/saveProject" method="post" class="am-form">
    <div class="am-tabs am-margin" data-am-tabs>
      <ul class="am-tabs-nav am-nav am-nav-tabs">
        <!-- <li class="am-active"><a href="#tab1">基本信息</a></li> -->
      </ul>

      <div class="am-tabs-bd">

        <div class="am-tab-panel am-fade am-in am-active" id="tab1">
        
            <div class="am-g am-margin-top">
              <div class="am-u-sm-4 am-u-md-2 am-text-right">
              项目名称
              </div>
              <div class="am-u-sm-8 am-u-md-4">
                <input type="text" class="am-input-sm" name="projectName" id="projectName" required>
              </div>
              <div class="am-hide-sm-only am-u-md-6">*必填</div>
            </div>

			<div class="am-g am-margin-top">
              <div class="am-u-sm-4 am-u-md-2 am-text-right">
            客户公司
              </div>
              <div class="am-u-sm-8 am-u-md-4">
                <select  name="customerCompanyId" id ="customerCompanyId" required>
                  	<option value="">请选择</option>
                  	<c:forEach items="${customerCompanyList }" var = "customerCompany" >
           				<option value="${customerCompany.customerCompanyId }" <c:if test="${customerCompany.customerCompanyId == project.customerCompanyId}">selected</c:if>>${customerCompany.customerCompanyName }</option>
           			</c:forEach>
                </select>
              </div>
              <div class="am-hide-sm-only am-u-md-6"> *必填 </div>
            </div>
          
	          <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">
	           客户负责人
	            </div>
	            <div class="am-u-sm-8 am-u-md-4">
                <select  name="customerId" id ="customerId" required>
                  	<option value="">请选择</option>
                  	<%-- <c:forEach items="${customerList }" var = "customer" >
           				<option value="${customer.customerId }" >${customer.customerName }</option>
           			</c:forEach> --%>
                </select>
                
              </div>
              <div class="am-hide-sm-only am-u-md-6"> *必填 </div>
	          </div>
          
          
	          <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">
	            接单部门
	            </div>
	            <div class="am-u-sm-8 am-u-md-4">
                <select  name="companyId" id ="companyId" required >
                  	<option value="">请选择</option>
                  	<c:forEach items="${companyList }" var = "company" >
           				<option value="${company.companyId }" >${company.companyName }</option>
           			</c:forEach>
                </select>
              </div>
              <div class="am-hide-sm-only am-u-md-6"> *必填 </div>
	          </div>

			
	          <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">
	           项目负责人
	            </div>
	            <div class="am-u-sm-8 am-u-md-4">
                <select  name="staffId1" id ="staffId1" required <c:if test="${permission == 0}">disabled</c:if>>
                  	<option value="">请选择</option>
                  	<c:forEach items="${staffList }" var = "staff" >
           				<option value="${staff.staffId }" <c:if test="${staff.staffId == staffId}">selected</c:if>>${staff.staffName }</option>
           			</c:forEach>
                </select>
                <c:if test="${permission == 0}"><input type="hidden" name="staffId1" value="${staffId}" /></c:if>
              </div>
              <div class="am-hide-sm-only am-u-md-6"> *必填 </div>
	          </div>

	            <div class="am-g am-margin-top">
	              <div class="am-u-sm-4 am-u-md-2 am-text-right">
	               报价
	              </div>
	              <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
	                <input type="text" class="am-input-sm" name="offer" id ="offer" placeholder="请输入数字" min="0" pattern="^([0-9]+)|([0-9]+(.[0-9]{1,2})?)$">
	              </div>
	            </div>
	            
	            <div class="am-g am-margin-top">
	              <div class="am-u-sm-4 am-u-md-2 am-text-right">
	              预定成交日期
	              </div>
	              <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
	                <input type="date" class="am-form-field am-input-sm" placeholder="时间" name="expectedDealDateString" id ="expectedDealDateString" required>
	              </div>
	              <div class="am-hide-sm-only am-u-md-6">*必填</div>
	            </div>
			
				<div class="am-g am-margin-top">
	              <div class="am-u-sm-4 am-u-md-2 am-text-right">
	               项目进度
	              </div>
	              <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
	                <!-- <input type="text" class="am-input-sm" name="projectSchedule" id ="projectSchedule"> -->
	                
	                <select data-am-selected="{btnSize:'sm',dropUp: 1}" name="projectSchedule" id ="projectSchedule" >
	                  	<option value="">请选择</option>
	                  	<c:forEach items="${projectSchedule }" var = "projectSchedule" >
							<option value="${projectSchedule.value}">${projectSchedule.value}</option>
						</c:forEach>
	                </select>
	                
	              </div>
	            </div>
      </div>
    </div>

	  <div class="am-margin">
	    <button type="submit" class="am-btn am-btn-secondary" >提交保存</button>
	  </div>
	  </div>
    </form>
  </div>
		
		<!-- ***** 分离出去 动态加载 end ***** -->
	</div>
	<!-- content end -->
</div>
</div>



<script type="text/javascript">

$("#customerCompanyId").change(function(){
	$.ajax({
        type: "POST",
        async:false,
        url: "project/getCompanyList",
        data : {
        	"companyId":$("#customerCompanyId").val()
        },
        success: function(list) {
        	if(list != null && list.length != 0) {
        		var customerId = $("#customerId");
            	$("option", customerId).remove(); //清空原有的选项 
            	
            	$.each(list, function(index, map) {
                    var option = "<option value='" + map.id + "'>" + map.name + "</option>";
                    customerId.append(option);
                });
        	}
        }
    });
});

</script>

</body>
</html>